Trò chơi đua xe động vật trong UNITY Engine
114.686 lượt xem;
1 using UnityEngine;
2 using System.Collections;
3
4 public class ActionSequence : ActionParallel{
5
6 private int index;
7
8 public ActionSequence() { }
9 public ActionSequence(params Action[] actions) {
10 for (int i = 0; i < actions.Length; i++)
11 {
12 this.myActions.Add(actions[i]);
13 }
14 }
15
16 public void AddActions(params Action[] actions)
17 {
18 for (int i = 0; i < actions.Length; i++)
19 {
20 this.myActions.Add(actions[i]);
21 }
22 }
23
24 public override bool Act(float delta)
25 {
26 if (index >= myActions.Count) return true;
27
28 try
29 {
30 if (myActions[index].Act(delta))
31 {
32 if (actor == null) return true;
33 index++;
34 if (index >= myActions.Count) return true;
35 }
36 return false;
37 }
38 finally { }
39 }
40
41 public override void restart()
42 {
43 base.restart();
44 index = 0;
45 }
46 }
2 using System.Collections;
3
4 public class ActionSequence : ActionParallel{
5
6 private int index;
7
8 public ActionSequence() { }
9 public ActionSequence(params Action[] actions) {
10 for (int i = 0; i < actions.Length; i++)
11 {
12 this.myActions.Add(actions[i]);
13 }
14 }
15
16 public void AddActions(params Action[] actions)
17 {
18 for (int i = 0; i < actions.Length; i++)
19 {
20 this.myActions.Add(actions[i]);
21 }
22 }
23
24 public override bool Act(float delta)
25 {
26 if (index >= myActions.Count) return true;
27
28 try
29 {
30 if (myActions[index].Act(delta))
31 {
32 if (actor == null) return true;
33 index++;
34 if (index >= myActions.Count) return true;
35 }
36 return false;
37 }
38 finally { }
39 }
40
41 public override void restart()
42 {
43 base.restart();
44 index = 0;
45 }
46 }